OBJ_HMAP= hmap.o \
          mod_hmap_state.o \
          mod_hmap_ode.o
#
# General settings -----------------------------------

PWD:=$(shell pwd)
BUILDDIR:=$(BUILDDIR)/LC

LIBS:=-lshared -llinsol -lode $(LIBS)
LDFLAGS:=$(LDFLAGS) -L$(LIBDIR)

# VPATH includes:
#   PWD for the source files (included by default)
#   PWD/testcases for the source files of the testcases
#   BUILDDIR for the .o prerequisites
#   LIBDIR for the libshared.a library
#   BINDIR for the final executable
VPATH:=./testcases $(BUILDDIR) $(LIBDIR) $(BINDIR)

# clear unfinished targets
.DELETE_ON_ERROR:
# define the phony targets
.PHONY: clean

# Main targets ---------------------------------------

hmap: $(OBJ_HMAP)
	cd $(BUILDDIR) && \
	  $(LD) $(LDFLAGS) $(OBJ_HMAP) $(LIBS) -o $(BINDIR)/hmap

# General rule: all the .o depend on the libshared library
%.o: %.f90 libshared.a liblinsol.a libode.a
	cd $(BUILDDIR) && \
	  $(FC) $(FFLAGS) $(MODFLAG)$(LIBDIR) -c $(PWD)/$<

clean:
	$(RM) $(BUILDDIR)/*.o $(BUILDDIR)/*.ilo $(BUILDDIR)/*.mod \
          $(BINDIR)/hmap

hmap.o: \
  mod_hmap_state.o \
  mod_hmap_ode.o

mod_hmap_ode.o: \
  mod_hmap_state.o

